/**
 * 
 */
package org.strangewt.demo.widgets;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.strangewt.widgets.WidgetHelper;

/**
 * Demonstrates how the <code>WidgetHelper</code> can get customized
 * for different projects. <br>
 * You have to subclass it and override the static methods.
 *  
 * @author strange optics
 *
 */
public class DemoWidgetHelper extends WidgetHelper {

	/**
	 * <code>Label</code> with text.
	 * @param parent
	 * @param text
	 * @return
	 */
	public static Label createLabel(Composite parent, String text) {
		Label label = new Label(parent, SWT.NONE);
		label.setText("Demo" + text);
		return label;
	}
	
	/**
	 * <code>Label</code> with text for multi column input fields.<br>
	 * - verticalAlignment = SWT.TOP
	 * @param parent
	 * @param text
	 * @return
	 */
	public static Label createLabelTop(Composite parent, String text) {
		Label label = new Label(parent, SWT.NONE);
		label.setText("Demo" + text);
		label.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
		return label;
	}
	
	/**
	 * <code>Text</code> with border that fills up a line.<br>
	 * - horizontalAlignment = SWT.FILL<br>
	 * - grabExcessHorizontalSpace = true
	 * @param parent
	 * @return
	 */
	public static Text createText(Composite parent) {
		Text text = new Text(parent, SWT.BORDER);
		text.setLayoutData(createGridDataForInputFields());
		text.setText("sets 'Demo' in front of the label text");
		return text;
	}
}
